<?php
	require_once('paths.inc');
	require_once(INCLUDE_PATH.'constants.inc');
	require_once('page.inc');
	require_once(DB_PATH.'db.inc');
	
	require_once('security.inc');
	require_once('utils.inc');	
	
	session_start();
	
	if (isset($_POST['trimite_erroare'])) {
		$errorMess = "";
		$mesaj = $_POST['mesaj_erroare'];
		$user_id = $_POST['user_id'];
		$client_id = $_POST['client_id'];
		$user_name = $_POST['user_name'];
		$user_prenume = $_POST['user_prenume'];
		
		if (strlen($mesaj) <= 5) {
			$errorMess = LANG_Error_Message_Too_Short;			
		}
		
		if ($errorMess == "") {
			$catre = "tricasoft@gmail.com, domnulnopcea@gmail.com, domnuprofesor@gmail.com";
	        
			if (($result = @mail($catre, "Contact - program softy - erroare in program", $mesaj, 'From: contact@programsofty.com')) !== TRUE)
				$_SESSION["notice_msg"] = LANG_MailSend_Faild;
			else 
	        	$_SESSION["notice_msg"] = LANG_Erroare_Trimisa;
		}
		else 
			error_msg($errorMess, "error.php?error=" . $_GET['error']);
	}
	
    select_language();
	//check_permissions(CT_PERM_PLATI);	
	html_header("LANG_trimite_eroare", null, "signal_error");
	
	select_js_language();
	$linkuri = array(LANG_Home => "home.php", LANG_Signal_Error => "");
	titlu_pagina($linkuri);
	
	output_error_msg();
	output_notice_msg();
?>
	
	<div align="left" class="container">
	
	<table id="wrapper" align="left" width="40%">
<!--        <form name="view_plati" id="view_plati" onsubmit="return (validateForm());">    -->
        <form name="view_plati" id="view_plati" action="error.php" method="POST" onsubmit="return true;">    
		    <thead>
			    <tr>
				    <th colspan="8"><?php echo LANG_trimite_eroare; ?></th>
			    </tr>
		    </thead>
		    <tr class="capTabel">
		    	<td colspan="2"><?php echo LANG_Erroare_Explicatie; ?></td>
		    </tr>
		    <tr class="capTabel">
			    <td colspan="2"><textarea name="mesaj_erroare" cols="85" rows="7"><?php if (isset($_POST['mesaj_erroare'])) echo $_POST['mesaj_erroare']; ?></textarea></td>
		    </tr>
		    <tr class="capTabel">
			    <td colspan="2">
			    	<div class="container">
						<?php buton_final_ok(LANG_Send_Message, "trimite_erroare"); ?>
					</div>
			    </td>
		    </tr>
		    <input type="hidden" name="error_code" value="<?php if (isset($_GET['error'])) echo $_GET['error']; else echo $_POST['error_code']; ?>">
		    <input type="hidden" name="user_id" value="<?php echo $_SESSION['user_logat']->id_user; ?>">
		    <input type="hidden" name="client_id" value="<?php echo $_SESSION['user_logat']->id_client; ?>">
		    <input type="hidden" name="user_name" value="<?php echo $_SESSION['user_logat']->nume; ?>">
		    <input type="hidden" name="user_prenume" value="<?php echo $_SESSION['user_logat']->prenume; ?>">
        </form>
	</table>		
		
	</div>
	
<?php 
	html_footer();
?>